package com.josework.springhelloworld.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.Month;
import java.util.*;
import java.util.Comparator;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
public class Student {
    private String id;
    private String name;
    private LocalDate birthday;
    private int age;
    private double score;

    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        List<Student> students2 = new ArrayList<>();
        students.add(new Student("1", "张三", LocalDate.of(2009, Month.JANUARY, 1), 12, 12.123));
        students2.add(new Student("1", "张三", LocalDate.of(2009, Month.JANUARY, 1), 12, 12.123));
        students.add(new Student("2", "李四", LocalDate.of(2010, Month.FEBRUARY, 2), 11, 22.123));
        students.add(new Student("3", "王五", LocalDate.of(2011, Month.MARCH, 3), 10, 32.123));
        students.removeAll(students2);

        Long count = students.stream().collect(Collectors.counting());
        Double avgScore = students.stream().collect(Collectors.averagingDouble(Student::getScore));
        Double intScore = students.stream().collect(Collectors.averagingInt(s -> (int) s.getScore()));
        Double longScore = students.stream().collect(Collectors.averagingLong(s -> (long) s.getScore()));
        Optional<Student> optionalStudent = students.stream().collect(Collectors.minBy(Comparator.comparing(Student::getAge)));
        Optional<Student> optionalStudent1 = students.stream().collect(Collectors.maxBy(Comparator.comparing(Student::getAge)));

        BigDecimal b = new BigDecimal(0.1);
        System.out.println(b);
        BigDecimal b2 = new BigDecimal("0.1");
        System.out.println(b2);

        List<String> ids = new ArrayList<>();
        ids.add("1");
        ids.add("2");
        String s = String.join(",",ids);
        Boolean aBoolean = Boolean.valueOf("-1");
        Boolean aBoolean1 = Boolean.valueOf("1");






    }


}
